package com.example.helloworld

import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.findNavController
import androidx.navigation.ui.setupWithNavController
import com.google.android.material.bottomnavigation.BottomNavigationView

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        try {
            val navView: BottomNavigationView = findViewById(R.id.nav_view)
            Log.d("MainActivity", "Found nav_view")
            
            val navHostFragment = supportFragmentManager
                .findFragmentById(R.id.nav_host_fragment) as NavHostFragment
            Log.d("MainActivity", "Found nav_host_fragment")
            
            val navController = navHostFragment.navController
            Log.d("MainActivity", "Got navController")
            
            navView.setupWithNavController(navController)
            Log.d("MainActivity", "Setup complete")
        } catch (e: Exception) {
            Log.e("MainActivity", "Navigation setup failed", e)
            e.printStackTrace()
        }
    }
}